﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CJJCH.Web
{
    public partial class NotePage : System.Web.UI.Page
    {
        CJJCH.BLL.T_NET_MenuSecond bll_menusecond = new BLL.T_NET_MenuSecond();
        CJJCH.BLL.T_NET_MenuThird bll_third = new BLL.T_NET_MenuThird();
        CJJCH.BLL.T_NET_Note bll_note = new BLL.T_NET_Note();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitRepater();
                ReapterDataBinding();
            }
        }

        private void InitRepater()
        {
            if (Request.QueryString["firstid"] != null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["firstid"].Trim()))
            {
                Top1.IIndex = Convert.ToInt32(Request.QueryString["firstid"]);
                Top1.FirstId = Convert.ToInt32(Request.QueryString["firstid"]);
                switch (Convert.ToInt32(Request.QueryString["firstid"]))
                {
                    case 1:
                        lstTitle.Text = "北京城建促进会-新闻动态";
                        ImaLest.ImageUrl = "Image/SubBanner1.gif";
                        break;
                    case 2:
                        lstTitle.Text = "北京城建促进会-技术标准";
                        ImaLest.ImageUrl = "Image/SubBanner2.gif";
                        break;
                    case 3:
                        lstTitle.Text = "北京城建促进会-教育培训";
                        ImaLest.ImageUrl = "Image/SubBanner4.gif";
                        break;
                    case 4:
                        lstTitle.Text = "北京城建促进会-专家评审";
                        ImaLest.ImageUrl = "Image/SubBanner6.gif";
                        break;
                    case 5:
                        lstTitle.Text = "北京城建促进会-科技推广";
                        ImaLest.ImageUrl = "Image/SubBanner7.gif";
                        break;
                    case 6:
                        lstTitle.Text = "北京城建促进会-协会刊物";
                        ImaLest.ImageUrl = "Image/SubBanner8.gif";
                        break;
                    case 7:
                        lstTitle.Text = "北京城建促进会-下载中心";
                        ImaLest.ImageUrl = "Image/SubBanner9.gif";
                        break;
                    case 8:
                        lstTitle.Text = "北京城建促进会-关于我们";
                        ImaLest.ImageUrl = "Image/SubBanner3.gif";
                        break; ;
                    default:
                        break;
                }
                if (Request.QueryString["secondid"] != null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["secondid"].Trim()))
                {

                    lblFID.Text = Request.QueryString["firstid"].Trim();
                    lblSID.Text = Request.QueryString["secondid"].Trim();
                    if (this.lblSID.Text == "30")
                    {
                        this.container.Style.Add("display","block");
                    }
                    Top1.SecondId = Convert.ToInt32(lblSID.Text);
                    CJJCH.Model.T_NET_MenuSecond menusecond = new Model.T_NET_MenuSecond();
                    menusecond = bll_menusecond.GetModelListPane(Convert.ToInt32(lblFID.Text), Convert.ToInt32(lblSID.Text));
                    if (menusecond != null)
                    {
                        lblNoteTitle.Text = menusecond.MenuName;
                        LeftMenu1.FirstId = menusecond.FirstID;
                        LeftMenu1.SecondId = menusecond.ID;
                        lblMID.Text = menusecond.MenuTypeID.ToString();

                        if (Request.QueryString["thirdid"] == null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["thirdid"].Trim()))
                        {
                            lblTID.Text = Request.QueryString["thirdid"];
                        }
                        else
                        {
                            lblTID.Text = "0";
                            LeftMenu1.ThirdId = 0;

                        }
                    }
                    else
                    {
                        Response.Redirect("error.aspx");
                    }
                }
                else
                {
                    lblFID.Text = Request.QueryString["firstid"].Trim();
                    CJJCH.Model.T_NET_MenuSecond menusecond = new Model.T_NET_MenuSecond();
                    menusecond = bll_menusecond.GetModelListPane(Convert.ToInt32(lblFID.Text), 0);
                    if (menusecond != null)
                    {

                        lblFID.Text = menusecond.FirstID.ToString();
                        lblSID.Text = menusecond.ID.ToString();
                        lblMID.Text = menusecond.MenuTypeID.ToString();
                        LeftMenu1.FirstId = menusecond.FirstID;
                        LeftMenu1.SecondId = menusecond.ID;
                        if (menusecond.HaveChild == true)//判断二级标题是否有子类如果有根据二级标题id获取到三级标题id如果无赋值为0
                        {
                            CJJCH.Model.T_NET_MenuThird menuthird = new Model.T_NET_MenuThird();
                            menuthird = bll_third.GetMinModel(menusecond.ID);
                            lblTID.Text = menuthird.ID.ToString();
                            LeftMenu1.ThirdId = menuthird.ID;
                        }
                        else
                        {
                            lblTID.Text = "0";
                            LeftMenu1.ThirdId = 0;
                        }
                    }
                    else
                    {
                        Response.Redirect("error.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("error.aspx");
            }

            if (Request.QueryString["thirdid"] != null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["thirdid"].Trim()))
            {
                Top1.ThirdId = Convert.ToInt32(Request.QueryString["thirdid"]);
            }
            if (Request.QueryString["keyword"] != null)
            {
                lblKeyWord.Text = Request.QueryString["keyword"].ToString();
                Top1.Keyword = lblKeyWord.Text;

            }

            if (Request.QueryString["typename"] != null)
            {

                lbltypeName.Text = Request.QueryString["typeName"].Trim();
                Top1.Typename = lbltypeName.Text;

            }
        }
        private void ReapterDataBinding()
        {
            CJJCH.Model.T_NET_Note note = new Model.T_NET_Note();
            note = bll_note.GetNoteAgo(Convert.ToInt32(lblSID.Text), Convert.ToInt32(lblTID.Text));
            if (note != null)
            {
                lblNoteTitle.Text = note.Menusecond.MenuName;
                if (note.DataNote != "")
                {
                    divNote.InnerHtml = note.DataNote;
                }
                else
                {
                    divNote.InnerHtml = "暂无信息";
                }
            }
            else
            {
                Response.Redirect("error.aspx");
            }
        }
    }
}